<?php
function smarty_function_pagers($params,&$smarty)
{
	$show_pagecount =SHOW_PAGECOUNT;	
	$pageCount = 0;	
	$currentPageID = 0;	
	$result = "";
	$midlparam = 1;
	$startIndex =0;
	$pageSize = 0;
	 
	
	foreach($params as $_key => $_val)
	{
        switch($_key) 
        {
            case 'show_pagecount':
                $$_key = (string)$_val;
                break;

            case 'pageCount':
                $$_key = (string)$_val;
                break;
                
        	case 'currentPageID':
                $$_key = (string)$_val;
                break;
        	
        	case 'midlparam':
                $$_key = (string)$_val;
                break;
                
            case 'startIndex':
                $$_key = (string)$_val;
                break;
                
		    case 'pageSize':
                $$_key = (string)$_val;
                break;
				
            default:
                break;
        }
    }
	if($pageSize != 0 )
	{
		$start = $currentPageID - $startIndex;
		if($start < 0 )
			$start = $startIndex - 1;
		else if ($start+1 >  $show_pagecount)
			$start = $startIndex + 1;
		else
			$start = $startIndex;	
			
		if($pageCount <	$show_pagecount )
			$end = $start + $pageCount -1;
		else	
			$end = $start + $show_pagecount -1;

		if($pageCount >1 && $pageSize != 0)
		{
			$forward = "←前" ;
			$after = "次→";
			if($currentPageID > 1 )
			{
				$result .= '<span class="style3"><a href="#" 
							onclick=pageSubmit('.($currentPageID - 1).','.($currentPageID).','.$start.')>'.$forward.'</a> </span>';		
			}
			else
			{
				$result .= '<span class="style3">'.$forward.'</span> ';
			}
			
			$result .= '｜';
			
			for ($i= $start; $i <= $end; $i++)
			{
				$Test = $start;
				if($i == $currentPageID)
				{
					$result .='<span class="style31">'.$i.'</span> '; 
					
				}
				else 
				{
					$result .= '<span class="style32"><a href="#" onclick=pageSubmit('.$i.','.$i.','.$start.')>'.$i.'</a></span> ';
				}
			}
			
		
			$result .= '｜';
			if($pageCount == 1 || $pageCount == $currentPageID)
			{
				$result .= '<span class="style3" >'.$after.'</span> ';
				
			}
			else
			{
			   $result .= "<a href='#' class='style3' onclick=pageSubmit(".($currentPageID + 1).','.($currentPageID).",".$start.")>".$after."</a>";	
			}
			echo "&nbsp;";
			echo $result;
		}
	}
	
}

?>